import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../widget/dnp_top_title_widget.dart';
import 'dnp_account_out_page.dart';
import 'dnp_sign_out_page.dart';

class DnpSettingPage extends StatefulWidget {

  final String phText;

  const DnpSettingPage({super.key,required this.phText});

  @override
  State<DnpSettingPage> createState() => _DnpSettingPageState();
}

class _DnpSettingPageState extends State<DnpSettingPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      body: Container(
        decoration: BoxDecoration(
          image: DecorationImage(
            image: AssetImage("assets/images/ic_base_bg.webp"),
            fit: BoxFit.cover,
          ),
        ),
        child: SafeArea(
          bottom: false,
          child: Column(
            children: [
              _titleWidget(),
              SizedBox(height: 14),
              _contentWidget()
            ],
          ),
        ),
      ),
    );
  }

  Widget _titleWidget() {
    return DnpTopTitleWidget(
      titleName: "Settings",
    );
  }

  Widget _contentWidget() {
    return Container(
      margin: EdgeInsets.only(left: 14,right: 14),
      height: 232,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.all(Radius.circular(20)),
        color: Colors.white,
        border: Border.all(
          color: Color(0xFF1D4AC8),
          width: 1.0
        )
      ),
      child: Column(
        children: [
          SizedBox(height: 14),
          Row(
            children: [
              SizedBox(width: 14),
              Image.asset(
                width: 73,
                height: 73,
                'assets/images/ic_setting_logo.webp'
              ),
              SizedBox(width: 17),
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Image.asset(
                      width: 117,
                      height: 23,
                      'assets/images/ic_setting_title.webp'
                  ),
                  SizedBox(height:3),
                  Text(
                    'V 1.0',
                    style: TextStyle(
                      fontSize: 14,
                      color: Color(0xFFADAEB1),
                    ),
                  )
                ],
              )
            ]
          ),
          SizedBox(height: 19),
          _accountWidget(),
          SizedBox(height: 14),
          _signOutWidget()
        ],
      ),
    );
  }

  Widget _accountWidget() {
    return Container(
      height: 49,
      margin: EdgeInsets.only(left: 14,right: 14),
      padding: EdgeInsets.only(left: 10,right: 10),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.all(Radius.circular(14)),
        color: Color(0xFFE9F5FF),
      ),
      child: GestureDetector(
        behavior: HitTestBehavior.translucent,
        onTap: (){
          Get.to(() => DnpAccountOutPage(phText: widget.phText,));
        },
        // DnpAccountOutPage
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Row(
              children: [
                Image.asset(
                    width: 37,
                    height: 37,
                    'assets/images/ic_setting_account.webp'
                ),
                SizedBox(width: 6),
                Text(
                  'Account cancellation',
                  style: TextStyle(
                    fontSize: 16,
                    fontWeight: FontWeight.w500,
                    color: Color(0xFF252630),
                  ),
                )
              ],
            ),
            Image.asset(
                width: 18,
                height: 18,
                'assets/images/ic_setting_arrow.webp'
            ),
          ],
        ),
      ),
    );
  }

  Widget _signOutWidget() {
    return GestureDetector(
      behavior: HitTestBehavior.translucent,
      onTap: (){
        Get.to(() => DnpSignOutPage(),opaque: false,duration: Duration.zero);
      },
      child: Container(
        height: 49,
        margin: EdgeInsets.only(left: 14,right: 14),
        padding: EdgeInsets.only(left: 10,right: 10),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.all(Radius.circular(14)),
          color: Color(0xFFE9F5FF),
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Row(
              children: [
                Image.asset(
                    width: 37,
                    height: 37,
                    'assets/images/ic_setting_account.webp'
                ),
                SizedBox(width: 6),
                Text(
                  'Sign out',
                  style: TextStyle(
                    fontSize: 16,
                    fontWeight: FontWeight.w500,
                    color: Color(0xFF252630),
                  ),
                )
              ],
            ),
            Image.asset(
                width: 18,
                height: 18,
                'assets/images/ic_setting_arrow.webp'
            ),
          ],
        ),
      ),
    );
  }
}
